package com.building18.mapper;

import com.building18.pojo.House;
import com.building18.pojo.dto.HouseDTO;
import com.building18.pojo.vo.HouseVO;
import com.building18.pojo.vo.StateVO;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface HouseMapper {

    List<House> selectHouse(@Param("houseDTO") HouseDTO houseDTO);

    @Select("select id,house_no from house_info")
    List<HouseVO> getHouseNoAndId();

    List<StateVO> getHouseStateNameAndId();

    @Insert("insert into house_info(id, house_no, floor, area, live_time, state, building_id, remarks) values(default, #{houseNo}, #{floor}, #{area}, #{liveTime}, #{state}, #{buildingId}, #{remarks})")
    Integer addHouse(House house);

    @Delete("delete from house_info where id = #{id}")
    Integer deleteHouse(Integer id);

    @Update("update house_info set house_no = #{houseNo}, floor = #{floor}, area = #{area}, live_time = #{liveTime}, state = #{state}, building_id = #{buildingId}, remarks = #{remarks} where id = #{id}")
    Integer updateHouse(House house);
}
